//
//  CurveViewController.m
//  GetPowerDBO
//
//  Created by 周博 on 2017/6/30.
//  Copyright © 2017年 BogoZhou. All rights reserved.
//

#import "CurveViewController.h"
#import "ChooseCalenderDateViewController.h"
#import "ChooseItemsInCurveViewController.h"

@interface CurveViewController () <ChooseCalenderDateViewControllerDelegate,ChooseItemsInCurveViewControllerDelegate>

@property (nonatomic,strong) NSMutableArray *dataArray;
@property (nonatomic,assign) NSInteger largeString;
@property (nonatomic,strong) UIView *topView;
@end

@implementation CurveViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self UISetting];
    if (_typString.integerValue == 1) {//我的历史数据
        [self loadListData];
    }else if (_typString.integerValue == 3){//我的提成，历史明细
        [self loadCommistionHistoryFunc];
    }else{//门店历史 和 达标
        [self loadData];
    }
    [self typeSetting];
}



- (void)UISetting{
    _labelShopName.text = _shopName;
    _dataArray = [NSMutableArray array];
    _labelStart.text = [BGDateHelper seeDayAroundToday:-8][0];
    
    NSString *startDateLonglong = [BGDateHelper getTimeStempByString:_labelStart.text havehh:NO];
    NSString *beginDateLongLong = [BGDateHelper getTimeStempByString:_beginDate havehh:NO];
    
    if (startDateLonglong.longLongValue < beginDateLongLong.longLongValue) {
        _labelStart.text = _beginDate;
    }
    
    _labelEnd.text = [BGDateHelper seeDayAroundToday:-1][0];
    _curveView.backgroundColor = [_curveView.backgroundColor colorWithAlphaComponent:0.4];
    
    _kEchartView = [[PYZoomEchartsView alloc] initWithFrame:CGRectMake(0, 0, _curveView.sizeWidth, _curveView.sizeHeight)];
//    _kEchartView.backgroundColor = [kWhiteColor colorWithAlphaComponent:0.5];
    _kEchartView.backgroundColor = kWhiteColor;
    [_curveView addSubview:_kEchartView];
}

- (void)initAll {
    PYOption *option ;
    if (_typString.integerValue ==1) {//我的历史
        option = [self standardLineOptionHistory];
    }else if(_typString.integerValue == 2){//达标
        option = [self standardLineOptionDaBiaoShop];
    }else if (_typString.integerValue == 3){//历史提成
        option = [self standardLineOptionCommistionHistory];
    }else{
        option = [self standardLineOptionSingleShop];
    }
    [_kEchartView setOption:option];
    [_kEchartView loadEcharts];
}

- (PYOption *)standardLineOptionHistory{
    NSMutableArray *dateArray = [NSMutableArray array];
    
    NSMutableArray * historyCharging_average_per_day_addA = [NSMutableArray array];
    NSMutableArray *historyStore_average_per_day_addA = [NSMutableArray array];
    NSMutableArray *historyStore_numA = [NSMutableArray array];
    NSMutableArray *historyCharging_numA = [NSMutableArray array];
    NSMutableArray *historyGuide_countA = [NSMutableArray array];
    NSMutableArray *historySub_countA = [NSMutableArray array];
    NSMutableArray *historyOnline_charging_numA = [NSMutableArray array];
    NSMutableArray *historyUse_charging_numA = [NSMutableArray array];
    NSMutableArray *historyOk_store_numA = [NSMutableArray array];
    NSMutableArray *historyCharging_rateA = [NSMutableArray array];

    
    NSMutableArray *wifi_numA = [NSMutableArray array];
    NSMutableArray *wifi_sub_countA = [NSMutableArray array];
    NSMutableArray *wifi_used_numA = [NSMutableArray array];

    NSMutableArray *mima_numA = [NSMutableArray array];
    NSMutableArray *mima_sub_countA = [NSMutableArray array];
    NSMutableArray *mima_used_numA = [NSMutableArray array];

    
//    NSArray *nameArray = @[@"单台日均涨粉",@"单店日均涨粉",@"已铺门店",@"已铺设备",@"当日新增",@"使用设备",@"达标门店",@"设备使用率"];
    NSMutableArray *nameArray = [NSMutableArray array];
    NSMutableArray*colorArray = [NSMutableArray array];
    
    
    for (CurveHistoryModel *model in _dataArray) {
        //当日新增
        NSInteger sub_count = model.sub_count.integerValue;
        [historySub_countA addObject:[NSNumber numberWithInteger:sub_count]];
        
        //线设备
        NSInteger use_charging_num = model.use_charging_num.integerValue;
        [historyUse_charging_numA addObject:[NSNumber numberWithInteger:use_charging_num]];
        
        //单台日均涨粉
        double charging_average_per_day_add = use_charging_num == 0 ? 0 : (double)sub_count/use_charging_num;
        NSInteger num = charging_average_per_day_add*100;
        double num2 = num/100.00;
        [historyCharging_average_per_day_addA addObject:[NSNumber numberWithDouble:num2]];
        
        //已铺门店
        NSInteger store_num = model.store_num.integerValue;
        [historyStore_numA addObject:[NSNumber numberWithInteger:store_num]];
        
        //单店日均涨粉
        double store_average_per_day_add = store_num == 0 ? 0 : (double)sub_count/store_num;
        num = store_average_per_day_add*100;
        num2 = num/100.00;
        [historyStore_average_per_day_addA addObject:[NSNumber numberWithDouble:num2]];
        

        //已铺设备
        NSInteger charging_num = model.charging_num.integerValue;
        [historyCharging_numA addObject:[NSNumber numberWithInteger:charging_num]];
        
        //设备使用率
        double charging_rate = charging_num == 0 ? 0 : (double)use_charging_num/charging_num;
        num = charging_rate*10000;
        num2 = num/100.00;
        
        [historyCharging_rateA addObject:[NSNumber numberWithDouble:num2]];
        
        NSInteger guide_count = model.guide_count.integerValue;
        [historyGuide_countA addObject:[NSNumber numberWithInteger:guide_count]];
        
        NSInteger online_charging_num = model.online_charging_num.integerValue;
        [historyOnline_charging_numA addObject:[NSNumber numberWithInteger:online_charging_num]];
        
        NSInteger ok_store_num = model.ok_store_num.integerValue;
        [historyOk_store_numA addObject:[NSNumber numberWithInteger:ok_store_num]];
        
        //日期
        [dateArray addObject:[BGDateHelper getTimeArrayByTimeString:[BGDateHelper getTimeStempByString:model.date havehh:NO]][9]];
        
        //wifi
        //wifi设备数
        NSInteger wifi_num = model.wifi_num.integerValue;
        [wifi_numA addObject:[NSNumber numberWithInteger:wifi_num]];
        
        //WiFi涨粉数
        NSInteger wifi_sub_count = model.wifi_sub_count.integerValue;
        [wifi_sub_countA addObject:[NSNumber numberWithInteger:wifi_sub_count]];
        
        //WiFi使用数
        NSInteger wifi_used_num = model.wifi_used_num.integerValue;
        [wifi_used_numA addObject:[NSNumber numberWithInteger:wifi_used_num]];
        
        //密码
        //密码设备数
        NSInteger mima_num = model.mima_num.integerValue;
        [mima_numA addObject:[NSNumber numberWithInteger:mima_num]];
        
        //密码涨粉数
        NSInteger mima_sub_count = model.mima_sub_count.integerValue;
        [mima_sub_countA addObject:[NSNumber numberWithInteger:mima_sub_count]];
        
        //密码使用数
        NSInteger mima_used_num = model.mima_used_num.integerValue;
        [mima_used_numA addObject:[NSNumber numberWithInteger:mima_used_num]];
        /*
         "wifi_num" = 2;
         "wifi_sub_count" = 0;
         "wifi_used_num" = 0;
         "mima_num" = 3;
         "mima_sub_count" = 0;
         "mima_used_num" = 0;
         */
    }
    
    return [PYOption initPYOptionWithBlock:^(PYOption *option) {
        option.titleEqual([PYTitle initPYTitleWithBlock:^(PYTitle *title) {
            //                        title.textEqual(@"未来一周气温变化")
            //                        .subtextEqual(@"纯属虚构");
        }])
        .tooltipEqual([PYTooltip initPYTooltipWithBlock:^(PYTooltip *tooltip) {
            tooltip.triggerEqual(PYTooltipTriggerAxis);
        }])
        .gridEqual([PYGrid initPYGridWithBlock:^(PYGrid *grid) {
            grid.xEqual(@40).x2Equal(@50);
        }])
        
        .addXAxis([PYAxis initPYAxisWithBlock:^(PYAxis *axis) {
            axis.typeEqual(PYAxisTypeCategory)
            .boundaryGapEqual(@NO)
            .addDataArr(dateArray);
            axis.axisLine.lineStyle.color = @"#32c340";
            axis.axisLine.lineStyle.color0 = @"#32c340";
            
            axis.axisLabel.textStyle.color = @"#32c340";
            axis.nameTextStyle.color = @"#32c340";
            axis.nameTextStyle.shadowColor = @"#32c340";

        }])
        .addYAxis([PYAxis initPYAxisWithBlock:^(PYAxis *axis) {
            axis.typeEqual(PYAxisTypeValue)
            .axisLabelEqual([PYAxisLabel initPYAxisLabelWithBlock:^(PYAxisLabel *axisLabel) {
                axisLabel.formatterEqual(@"{value}");
                axisLabel.textStyle.color = @"#000000";
            }]);
            axis.axisLine.lineStyle.color = @"#32c340";
            axis.axisLine.lineStyle.color0 = @"#32c340";
        }]);
        if (_charging_average_per_day_add) {
            [nameArray addObject:@"单台日均涨粉"];
            [colorArray addObject:@"#5fa1c4"];
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"单台日均涨粉")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(historyCharging_average_per_day_addA)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }

        if (_store_average_per_day_add) {
            [nameArray addObject:@"单店日均涨粉"];
            [colorArray addObject:@"#5f79c4"];
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"单店日均涨粉")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(historyStore_average_per_day_addA)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }

        if (_store_num) {
            [nameArray addObject:@"已铺门店"];
            [colorArray addObject:@"#c45f5f"];

            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"已铺门店")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(historyStore_numA)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }

        if (_charging_num) {
            [nameArray addObject:@"已铺设备"];
            [colorArray addObject:@"#b25fc4"];

            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"已铺设备")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(historyCharging_numA)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }

        if (_sub_count) {
            [nameArray addObject:@"当日新增"];
            [colorArray addObject:@"#9dc45f"];

            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"当日新增")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(historySub_countA)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }
        if (_use_charging_num) {
            [nameArray addObject:@"使用设备"];
            [colorArray addObject:@"#5fc487"];

            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"使用设备")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(historyUse_charging_numA)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }

        if (_ok_store_num) {
            [nameArray addObject:@"达标门店"];
            [colorArray addObject:@"#c4b05f"];

            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"达标门店")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(historyOk_store_numA)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }

        if (_charging_rate) {
            [nameArray addObject:@"设备使用率"];
            [colorArray addObject:@"#bfd3b7"];
            
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"设备使用率")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(historyCharging_rateA)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
            }]);
        }
        
#pragma mark - 新增 wifi 和 密码
        if (_wifi_num) {
            [nameArray addObject:@"WiFi设备数"];
            [colorArray addObject:@"#3cb371"];
            
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"WiFi设备数")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(wifi_numA)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
            }]);
        }
        
        if (_wifi_sub_count) {
            [nameArray addObject:@"WiFi设备涨粉数"];
            [colorArray addObject:@"#cd5c5c"];
            
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"WiFi设备涨粉数")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(wifi_sub_countA)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
            }]);
        }
        
        if (_wifi_used_num) {
            [nameArray addObject:@"WiFi设备使用数"];
            [colorArray addObject:@"#66ffff"];
            
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"WiFi设备使用数")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(wifi_used_numA)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
            }]);
        }
#pragma mark - 密码
        if (_mima_num) {
            [nameArray addObject:@"密码设备数"];
            [colorArray addObject:@"#6600ff"];
            
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"密码设备数")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(mima_numA)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
            }]);
        }
        
        if (_mima_sub_count) {
            [nameArray addObject:@"密码设备涨粉数"];
            [colorArray addObject:@"#660099"];
            
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"密码设备涨粉数")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(mima_sub_countA)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
            }]);
        }
        
        if (_mima_used_num) {
            [nameArray addObject:@"密码设备使用数"];
            [colorArray addObject:@"#FFB6C1"];
            
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"密码设备使用数")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(mima_used_numA)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
            }]);
        }

        option.legendEqual([PYLegend initPYLegendWithBlock:^(PYLegend *legend) {
            legend.dataEqual(nameArray);
            
        }]);
        
        option.color =  colorArray;
    }];
}

- (PYOption *)standardLineOptionSingleShop{
    NSMutableArray *growth_fans_numArray = [NSMutableArray array];
    NSMutableArray *total_charging_numArray = [NSMutableArray array];
    NSMutableArray *online_charging_numArray = [NSMutableArray array];
    NSMutableArray *used_charging_numArray = [NSMutableArray array];
    NSMutableArray *average_per_day_addArray = [NSMutableArray array];
    NSMutableArray *charging_rateArray = [NSMutableArray array];
    NSMutableArray *dabiaoArray = [NSMutableArray array];
    NSMutableArray *dateArray = [NSMutableArray array];
    
    
    NSMutableArray *nameArray = [NSMutableArray array];
    NSMutableArray*colorArray = [NSMutableArray array];
    
    for (CurveModel *model in _dataArray) {
        NSInteger growth_fans_num = model.growth_fans_num.integerValue;
        [growth_fans_numArray addObject:[NSNumber numberWithInteger:growth_fans_num]];

        NSInteger total_charging_num = model.total_charging_num.integerValue;
        [total_charging_numArray addObject:[NSNumber numberWithInteger:total_charging_num]];

        NSInteger online_charging_num = model.online_charging_num.integerValue;
        [online_charging_numArray addObject:[NSNumber numberWithInteger:online_charging_num]];

        NSInteger used_charging_num = model.used_charging_num.integerValue;
        [used_charging_numArray addObject:[NSNumber numberWithInteger:used_charging_num]];

        double average_per_day_add = total_charging_num == 0 ? 0 : model.growth_fans_num.doubleValue/total_charging_num;
        [average_per_day_addArray addObject:[NSNumber numberWithDouble:average_per_day_add]];
        
        //使用率
        double charging_rate = total_charging_num == 0 ? 0 : (double)used_charging_num/total_charging_num;
//        NSInteger num = charging_rate*10000;
//        double num2 = num/100.00;
        [charging_rateArray addObject:[NSNumber numberWithDouble:charging_rate]];

        NSInteger dabiao = model.is_ok.integerValue;
        [dabiaoArray addObject:[NSNumber numberWithInteger:dabiao]];

        [dateArray addObject:[BGDateHelper getTimeArrayByTimeString:[BGDateHelper getTimeStempByString:model.date havehh:NO]][9]];
    }

//    if (_typString.integerValue == 0) {
//        [self creatTopViewWithRiJunZhangFen:growth_fans_numArray shebeishiyong:used_charging_numArray zongshebei:total_charging_numArray];
//    }
    
    return [PYOption initPYOptionWithBlock:^(PYOption *option) {
        option.titleEqual([PYTitle initPYTitleWithBlock:^(PYTitle *title) {
            //                        title.textEqual(@"未来一周气温变化")
            //                        .subtextEqual(@"纯属虚构");
        }])
        .tooltipEqual([PYTooltip initPYTooltipWithBlock:^(PYTooltip *tooltip) {
            tooltip.triggerEqual(PYTooltipTriggerAxis);
        }])
        .gridEqual([PYGrid initPYGridWithBlock:^(PYGrid *grid) {
            grid.xEqual(@40).x2Equal(@50);
        }])
        
        .addXAxis([PYAxis initPYAxisWithBlock:^(PYAxis *axis) {
            axis.typeEqual(PYAxisTypeCategory)
            .boundaryGapEqual(@NO)
            .addDataArr(dateArray);
            
        }])
        .addYAxis([PYAxis initPYAxisWithBlock:^(PYAxis *axis) {
            axis.typeEqual(PYAxisTypeValue)
            .axisLabelEqual([PYAxisLabel initPYAxisLabelWithBlock:^(PYAxisLabel *axisLabel) {
                axisLabel.formatterEqual(@"{value}");
            }]);
        }]);
        if (_growth_fans_num) {
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                [nameArray addObject:@"涨粉数"];
                [colorArray addObject:@"#5fa1c4"];
                series.nameEqual(@"涨粉数")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(growth_fans_numArray)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }
        if (_total_charging_num) {
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                [nameArray addObject:@"总设备"];
                [colorArray addObject:@"#5f79c4"];
                series.nameEqual(@"总设备")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(total_charging_numArray)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }
        
        if (_used_charging_num) {
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                [nameArray addObject:@"使用设备"];
                [colorArray addObject:@"#c45f5f"];
                series.nameEqual(@"使用设备")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(used_charging_numArray)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }
        
        if (_average_per_day_add) {
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                [nameArray addObject:@"单台日均"];
                [colorArray addObject:@"#b25fc4"];
                series.nameEqual(@"单台日均")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(average_per_day_addArray)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }

        if (_charging_rate) {
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                [nameArray addObject:@"平均在线数"];
                [colorArray addObject:@"#9dc45f"];
                series.nameEqual(@"平均在线数")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(charging_rateArray)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }

        if (_dabiao) {
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                [nameArray addObject:@"达标"];
                [colorArray addObject:@"#5fc487"];
                series.nameEqual(@"达标")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(dabiaoArray)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }
        
        option.legendEqual([PYLegend initPYLegendWithBlock:^(PYLegend *legend) {
            legend.dataEqual(nameArray);
        }]);
        option.color = colorArray;
    }];
}

- (PYOption *)standardLineOptionCommistionHistory{
    NSMutableArray *history_ok_numArray = [NSMutableArray array];
    NSMutableArray *history_store_numArray = [NSMutableArray array];
    NSMutableArray *history_moneyArray = [NSMutableArray array];
    NSMutableArray *today_ok_numArray = [NSMutableArray array];
    NSMutableArray *today_store_numArray = [NSMutableArray array];
    NSMutableArray *today_moneyArray = [NSMutableArray array];
    NSMutableArray *merge_moneyArray = [NSMutableArray array];

    NSMutableArray *dateArray = [NSMutableArray array];
    
    NSMutableArray *nameArray = [NSMutableArray array];
    NSMutableArray*colorArray = [NSMutableArray array];
    
    NSInteger num ;
    double num2;
    for (CommistionModel *model in _dataArray) {

        //当日历史已铺店铺达标数
        [history_ok_numArray addObject:[ NSNumber numberWithInteger:model.history_ok_num.integerValue]];
        
        //当日历史已铺店铺
        [history_store_numArray addObject:[NSNumber numberWithInteger:model.history_store_num.integerValue]];
        
        //当日历史已铺店铺达标提成
        num = model.history_money.doubleValue*100;
        num2 = num/100.00;
        [history_moneyArray addObject:[NSNumber numberWithDouble:num2]];
        
        //当日已铺店铺达标
        [today_ok_numArray addObject:[NSNumber numberWithInteger:model.today_ok_num.integerValue]];
        
        //当日已铺店铺
        [today_store_numArray addObject:[NSNumber numberWithInteger:model.today_store_num.integerValue]];
        
        //当日已铺店铺达标提成
        num = model.today_money.doubleValue*100;
        num2 = num/100.00;
        [today_moneyArray addObject:[NSNumber numberWithDouble:num2]];
        
        //当日提成 （默认显示这个）
        num = model.merge_money.doubleValue*100;
        num2 = num/100.00;
        [merge_moneyArray addObject:[NSNumber numberWithDouble:num2]];
        
        [dateArray addObject:[BGDateHelper getTimeArrayByTimeString:[BGDateHelper getTimeStempByString:model.date havehh:NO]][9]];
    }

    return [PYOption initPYOptionWithBlock:^(PYOption *option) {
        option.tooltipEqual([PYTooltip initPYTooltipWithBlock:^(PYTooltip *tooltip) {
            tooltip.triggerEqual(PYTooltipTriggerAxis);
        }])
        .gridEqual([PYGrid initPYGridWithBlock:^(PYGrid *grid) {
            grid.xEqual(@40).x2Equal(@50);
        }])
        
        .addXAxis([PYAxis initPYAxisWithBlock:^(PYAxis *axis) {
            axis.typeEqual(PYAxisTypeCategory)
            .boundaryGapEqual(@NO)
            .addDataArr(dateArray);
            
        }])
        .addYAxis([PYAxis initPYAxisWithBlock:^(PYAxis *axis) {
            axis.typeEqual(PYAxisTypeValue)
            .axisLabelEqual([PYAxisLabel initPYAxisLabelWithBlock:^(PYAxisLabel *axisLabel) {
                axisLabel.formatterEqual(@"{value}");
            }]);
        }]);
        if (_history_ok_num) {
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                [nameArray addObject:@"当日历史已铺店铺达标数"];
                [colorArray addObject:@"#5fa1c4"];
                series.nameEqual(@"当日历史已铺店铺达标数")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(history_ok_numArray)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }
        if (_history_store_num) {
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                [nameArray addObject:@"当日历史已铺店铺"];
                [colorArray addObject:@"#5f79c4"];
                series.nameEqual(@"当日历史已铺店铺")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(history_store_numArray)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }
        
        if (_history_money) {
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                [nameArray addObject:@"当日历史已铺店铺达标提成"];
                [colorArray addObject:@"#c45f5f"];
                series.nameEqual(@"当日历史已铺店铺达标提成")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(history_moneyArray)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }
        
        if (_today_ok_num) {
            [nameArray addObject:@"当日已铺店铺达标"];
            [colorArray addObject:@"#b25fc4"];
            
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"当日已铺店铺达标")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(today_ok_numArray)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }
        
        if (_today_store_num) {
            [nameArray addObject:@"当日已铺店铺"];
            [colorArray addObject:@"#9dc45f"];
            
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"当日已铺店铺")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(today_store_numArray)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }
        if (_today_money) {
            [nameArray addObject:@"当日已铺店铺达标提成"];
            [colorArray addObject:@"#5fc487"];
            
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"当日已铺店铺达标提成")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(today_moneyArray)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }
        
        if (_merge_money) {
            [nameArray addObject:@"当日提成"];
            [colorArray addObject:@"#c4b05f"];
            
            option.addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
                series.nameEqual(@"当日提成")
                .typeEqual(PYSeriesTypeLine)
                .dataEqual(merge_moneyArray)
                
                .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                    markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
                }]);
                
            }]);
        }

        
        option.legendEqual([PYLegend initPYLegendWithBlock:^(PYLegend *legend) {
            legend.dataEqual(nameArray);
        }]);
        option.color = colorArray;
    }];
}

- (PYOption *)standardLineOptionDaBiaoShop{
    NSMutableArray *growth_fans_numArray = [NSMutableArray array];
    NSMutableArray *total_charging_numArray = [NSMutableArray array];
    NSMutableArray *online_charging_numArray = [NSMutableArray array];
    NSMutableArray *used_charging_numArray = [NSMutableArray array];
    //    NSMutableArray *average_per_day_addArray = [NSMutableArray array];
//    NSMutableArray *charging_rateArray = [NSMutableArray array];
    NSMutableArray *dabiaoArray = [NSMutableArray array];
    NSMutableArray *dateArray = [NSMutableArray array];
    
    for (CurveModel *model in _dataArray) {
        NSInteger growth_fans_num = model.growth_fans_num.integerValue;
        [growth_fans_numArray addObject:[NSNumber numberWithInteger:growth_fans_num]];
        
        NSInteger total_charging_num = model.total_charging_num.integerValue;
        [total_charging_numArray addObject:[NSNumber numberWithInteger:total_charging_num]];
        
        NSInteger online_charging_num = model.online_charging_num.integerValue;
        [online_charging_numArray addObject:[NSNumber numberWithInteger:online_charging_num]];
        
        NSInteger used_charging_num = model.used_charging_num.integerValue;
        [used_charging_numArray addObject:[NSNumber numberWithInteger:used_charging_num]];
        
        //        double average_per_day_add = model.average_per_day_add.doubleValue;
        //        [average_per_day_addArray addObject:[NSNumber numberWithDouble:average_per_day_add]];
        //
        
//        [charging_rateArray addObject:[NSNumber numberWithDouble:num2]];
        
        NSInteger dabiao = model.is_ok.integerValue;
        [dabiaoArray addObject:[NSNumber numberWithInteger:dabiao]];
        
        [dateArray addObject:[BGDateHelper getTimeArrayByTimeString:[BGDateHelper getTimeStempByString:model.date havehh:NO]][9]];
    }
    
//    if (_typString.integerValue == 0) {
//        [self creatTopViewWithRiJunZhangFen:growth_fans_numArray shebeishiyong:used_charging_numArray zongshebei:total_charging_numArray];
//    }
    
    return [PYOption initPYOptionWithBlock:^(PYOption *option) {
        option.titleEqual([PYTitle initPYTitleWithBlock:^(PYTitle *title) {
            //                        title.textEqual(@"未来一周气温变化")
            //                        .subtextEqual(@"纯属虚构");
        }])
        .tooltipEqual([PYTooltip initPYTooltipWithBlock:^(PYTooltip *tooltip) {
            tooltip.triggerEqual(PYTooltipTriggerAxis);
        }])
        .gridEqual([PYGrid initPYGridWithBlock:^(PYGrid *grid) {
            grid.xEqual(@40).x2Equal(@50);
        }])
        .legendEqual([PYLegend initPYLegendWithBlock:^(PYLegend *legend) {
            legend.dataEqual(@[@"达标"]);
        }])
        .addXAxis([PYAxis initPYAxisWithBlock:^(PYAxis *axis) {
            axis.typeEqual(PYAxisTypeCategory)
            .boundaryGapEqual(@NO)
            .addDataArr(dateArray);
            
        }])
        .addYAxis([PYAxis initPYAxisWithBlock:^(PYAxis *axis) {
            axis.typeEqual(PYAxisTypeValue)
            .axisLabelEqual([PYAxisLabel initPYAxisLabelWithBlock:^(PYAxisLabel *axisLabel) {
                axisLabel.formatterEqual(@"{value}");
            }]);
        }])

        .addSeries([PYSeries initPYSeriesWithBlock:^(PYSeries *series) {
            series.nameEqual(@"达标")
            .typeEqual(PYSeriesTypeLine)
            .dataEqual(dabiaoArray)
            
            .markLineEqual([PYMarkLine initPYMarkLineWithBlock:^(PYMarkLine *markLine) {
                markLine.addDataArr(@[@{@"type" : @"average", @"name": @"平均值"}]);
            }]);
            
        }]);
    }];
}


#pragma mark - 网络请求

- (void)loadData{

    [self.hub hideAnimated:YES];
    
    self.hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    // Set the label text.
    self.hub.label.text = NSLocalizedString(@"加载中...", @"HUD loading title");
    [[AFClient shareInstance] SingleShopSearchByEid:kUserId sid:_shopId start_date:_labelStart.text end_date:_labelEnd.text progressBlock:nil success:^(id responseBody) {
        [self.hub hideAnimated:YES];
        if ([responseBody[@"code"] integerValue] == 200) {
            [_dataArray removeAllObjects];
            _largeString = 0;
            for (NSDictionary *dic  in responseBody[@"data"]) {
                CurveModel *model = [[CurveModel alloc] init];
                [model setValuesForKeysWithDictionary:dic];

                _largeString = _largeString > model.growth_fans_num.integerValue ? _largeString : model.growth_fans_num.integerValue;
                _largeString = _largeString > model.total_charging_num.integerValue ? _largeString : model.total_charging_num.integerValue;
                _largeString = _largeString > model.online_charging_num.integerValue ? _largeString : model.online_charging_num.integerValue;
                _largeString = _largeString > model.used_charging_num.integerValue ? _largeString : model.used_charging_num.integerValue;
                _largeString = _largeString > model.average_per_day_add.integerValue ? _largeString : model.average_per_day_add.integerValue;
                _largeString = _largeString > model.charging_rate.integerValue ? _largeString : model.charging_rate.integerValue;

                [_dataArray addObject:model];
            }
            NSLog(@"%ld",_largeString);
            _largeString = (_largeString%5) > 0 ? (_largeString/5 +1) *5 : _largeString;
            NSLog(@"%ld",_largeString);
            [self initAll];
        }else{
            kAlert(responseBody[@"message"]);
        }
        
    } failure:^(NSError *error) {
        [self.hub hideAnimated: YES];
    }];
}

- (void)loadListData{
    [self.hub hideAnimated:YES];
    
    self.hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    // Set the label text.
    self.hub.label.text = NSLocalizedString(@"加载中...", @"HUD loading title");
    
    [[AFClient shareInstance] userHistorySearchByEid:kUserId start_date:_labelStart.text end_date:_labelEnd.text progressBlock:nil success:^(id responseBody) {
        [self.hub hideAnimated: YES];

        if ([responseBody[@"code"] integerValue] == 200) {
            [_dataArray removeAllObjects];
            for (NSDictionary *dic  in responseBody[@"data"]) {
                CurveHistoryModel *model = [[CurveHistoryModel alloc] init];
                [model setValuesForKeysWithDictionary:dic];

                [_dataArray addObject:model];
            }

            [self initAll];
        }else{
            kAlert(responseBody[@"message"]);
        }
    } failure:^(NSError *error) {
        [self.hub hideAnimated: YES];

    }];
}

- (void)loadCommistionHistoryFunc{
    
    [self.hub hideAnimated:YES];
    
    self.hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    // Set the label text.
    self.hub.label.text = NSLocalizedString(@"加载中...", @"HUD loading title");
    
    [[AFClient shareInstance] GetCommistionHistoryInfoByEid:kUserId start_date:_labelStart.text end_date:_labelEnd.text progressBlock:nil success:^(id responseBody) {
        [self.hub hideAnimated: YES];
        
        if ([responseBody[@"code"] integerValue] == 200) {
            [_dataArray removeAllObjects];
            for (NSDictionary *dic  in responseBody[@"data"]) {
                CommistionModel *model = [[CommistionModel alloc] init];
                [model setValuesForKeysWithDictionary:dic];
                
                [_dataArray addObject:model];
            }
            
            [self initAll];
        }else{
            [self.hub hideAnimated: YES];

            kAlert(responseBody[@"message"]);
        }
    } failure:^(NSError *error) {
        [self.hub hideAnimated: YES];

    }];
}

#pragma mark - 创建统计

- (void)creatTopViewWithRiJunZhangFen:(NSMutableArray *)rijunA shebeishiyong:(NSMutableArray *)shebeishiyongA zongshebei:(NSMutableArray *)zongshebeiA{
    [_topView removeFromSuperview];
    _topView = nil;
    
    _topView = [[UIView alloc] initWithFrame:CGRectMake(kScreenSize.width - 120, _curveView.orginY + 30, 120, 60)];
    _topView.backgroundColor = kClearColor;
    [self.view addSubview:_topView];
    [self.view bringSubviewToFront:_topView];
    
    UILabel *rijunzhangfen = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 120, 20)];
    UILabel *shebeishiyong = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, 120, 20)];
    rijunzhangfen.backgroundColor = kClearColor;
    shebeishiyong.backgroundColor = kClearColor;
    
    rijunzhangfen.font = [UIFont systemFontOfSize:12];
    shebeishiyong.font = [UIFont systemFontOfSize:12];
    
    [_topView addSubview:rijunzhangfen];
    [_topView addSubview:shebeishiyong];
    
    NSInteger rijun = 0;
    NSInteger shebei = 0;
    NSInteger zongshebei = 0;
    
    for (NSNumber *num in rijunA) {
        rijun += num.integerValue;
    }
    
    for (NSNumber *num in shebeishiyongA) {
        shebei += num.integerValue;
    }
    
    for (NSNumber *num in zongshebeiA) {
        zongshebei += num.integerValue;
    }
    
    if (rijunA.count != 0) {
        rijunzhangfen.text = [NSString stringWithFormat:@"日均涨粉:%.2lf",(double)rijun/rijunA.count];
    }else{
        rijunzhangfen.hidden = YES;
    }
    
    if (zongshebei != 0) {
        shebeishiyong.text = [NSString stringWithFormat:@"设备使用率%.2lf%%",((double)shebei/zongshebei)*100];
    }else{
        shebeishiyong.hidden = YES;
    }
    
}


#pragma mark - 点击事件

- (IBAction)backButtonClick:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

//点击问号
- (IBAction)wenhaoButtonClick:(UIButton *)sender {
    NSString *message = @"1、达标\n0 没有达标 1已经达标\n2、日均涨粉\n计算的是选中的日期范围内，平均每天的\n3、设备使用率\n计算的是选中的日期范围内，平均每天的\n4、单日均涨粉\n单店日均涨粉\n5、使用充电宝\n当天使用的充电宝\n6、使用充电宝\n当天使用的充电宝\n7、达标\n达标店铺数目\n8、使用率\n充电宝使用率";
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:message preferredStyle:UIAlertControllerStyleAlert];

    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    //paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
    paragraphStyle.alignment = NSTextAlignmentLeft;
    //行间距
    paragraphStyle.lineSpacing = 5.0;
    NSDictionary * attributes = @{NSFontAttributeName : [UIFont systemFontOfSize:14.0], NSParagraphStyleAttributeName : paragraphStyle};
    NSMutableAttributedString *attributedTitle = [[NSMutableAttributedString alloc] initWithString:message];
    [attributedTitle addAttributes:attributes range:NSMakeRange(0, message.length)];
    // 下面这句话用了KVC ，将attributes的值给了alert
    [alert setValue:attributedTitle forKey:@"attributedMessage"];//attributedTitle\attributedMessage
    //end ---
    
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    }];
    
    [alert addAction:action];
    [self presentViewController:alert animated:YES completion:nil];
}


//101开始时间 ； 102结束时间
- (IBAction)dateChooseButtonClick:(UIButton *)sender {
    UIStoryboard *storyboard = kMainStroyboard;
    
    ChooseCalenderDateViewController *chooseCalenderDateVC = [storyboard instantiateViewControllerWithIdentifier:@"ChooseCalenderDateViewController"];
    chooseCalenderDateVC.beginDate = _beginDate;
    
    chooseCalenderDateVC.start = _labelStart.text;
    
    chooseCalenderDateVC.end = _labelEnd.text;
    
    chooseCalenderDateVC.delegate = self;
    
    [self presentViewController:chooseCalenderDateVC animated:YES completion:nil];

}

- (void)typeSetting{
    _charging_average_per_day_add = YES;
    _store_average_per_day_add = YES;
    _store_num = NO;
    _charging_num = NO;
    _sub_count = NO;
    _use_charging_num = NO;
    _ok_store_num = NO;
    _charging_rate = NO;
    
    _growth_fans_num = YES;
    _total_charging_num = NO;
    _used_charging_num = YES;
    _average_per_day_add = NO;
    _charging_rate = NO;
    _dabiao = NO;
    _wifi_num = NO;
    _wifi_sub_count = NO;
    _wifi_used_num = NO;
    _mima_num = NO;
    _mima_sub_count = NO;
    _mima_used_num = NO;
    
    _history_ok_num = NO;
    _history_store_num = NO;
    _history_money = NO;
    _today_ok_num = NO;
    _today_store_num = NO;
    _today_money = NO;
    _merge_money = YES;
}

- (IBAction)chooseItemsButtonClick:(UIButton *)sender {
    ChooseItemsInCurveViewController *chooseItems =[[ChooseItemsInCurveViewController alloc] init];
    chooseItems.modalPresentationStyle = UIModalPresentationOverFullScreen;
    chooseItems.type = _typString;
    chooseItems.viewFrame = _buttonItems.frame;
    chooseItems.delegate = self;
    if (_typString.integerValue == 1) {//我的历史
        [chooseItems getHistoryPersonInfoByCharging_average_per_day_add:_charging_average_per_day_add
                                              store_average_per_day_add:_store_average_per_day_add
                                                              store_num:_store_num
                                                           charging_num:_charging_num
                                                              sub_count:_sub_count
                                                       use_charging_num:_use_charging_num
                                                           ok_store_num:_ok_store_num
                                                          charging_rate:_charging_rate
                                                               wifi_num:_wifi_num
                                                         wifi_sub_count:_wifi_sub_count
                                                          wifi_used_num:_wifi_used_num
                                                               mima_num:_mima_num
                                                         mima_sub_count:_mima_sub_count
                                                          mima_used_num:_mima_used_num];
        
    }else if (_typString.integerValue == 3){
        [chooseItems getCommistionHistoryByHistory_ok_num:_history_ok_num
                                        history_store_num:_history_store_num
                                            history_money:_history_money
                                             today_ok_num:_today_ok_num
                                          today_store_num:_today_store_num
                                              today_money:_today_money
                                              merge_money:_merge_money];
    }
    else{
        [chooseItems getSingleShopInfoByGrowth_fans_num:_growth_fans_num
                                     total_charging_num:_total_charging_num
                                      used_charging_num:_used_charging_num
                                    average_per_day_add:_average_per_day_add
                                          charging_rate:_charging_rate dabiao:_dabiao];
    }
    
    [self presentViewController:chooseItems animated:NO completion:nil];
}

#pragma mark - ChooseItemsInCurveViewControllerDelegate

- (void)showHistoryPersonInfoWithCharging_average_per_day_add:(NSNumber *)charging_average_per_day_add store_average_per_day_add:(NSNumber *)store_average_per_day_add store_num:(NSNumber *)store_num charging_num:(NSNumber *)charging_num sub_count:(NSNumber *)sub_count use_charging_num:(NSNumber *)use_charging_num ok_store_num:(NSNumber *)ok_store_num charging_rate:(NSNumber *)charging_rate wifi_num:(NSNumber *)wifi_num wifi_sub_count:(NSNumber *)wifi_sub_count wifi_used_num:(NSNumber *)wifi_used_num mima_num:(NSNumber *)mima_num mima_sub_count:(NSNumber *)mima_sub_count mima_used_num:(NSNumber *)mima_used_num{
    _charging_average_per_day_add = charging_average_per_day_add.boolValue;
    _store_average_per_day_add = store_average_per_day_add.boolValue;
    _store_num = store_num.boolValue;
    _charging_num = charging_num.boolValue;
    _sub_count = sub_count.boolValue;
    _use_charging_num = use_charging_num.boolValue;
    _ok_store_num = ok_store_num.boolValue;
    _charging_rate = charging_rate.boolValue;
    
    _wifi_num = wifi_num.boolValue;
    _wifi_sub_count = wifi_sub_count.boolValue;
    _wifi_used_num = wifi_used_num.boolValue;
    
    _mima_num = mima_num.boolValue;
    _mima_sub_count = mima_sub_count.boolValue;
    _mima_used_num = mima_used_num.boolValue;
    [self initAll];
    
}

- (void)showSingleShopInfoWithGrowth_fans_num:(NSNumber *)growth_fans_num total_charging_num:(NSNumber *)total_charging_num used_charging_num:(NSNumber *)used_charging_num average_per_day_add:(NSNumber *)average_per_day_add charging_rate:(NSNumber *)charging_rate dabiao:(NSNumber *)dabiao{
    _growth_fans_num = growth_fans_num.boolValue;
    _total_charging_num = total_charging_num.boolValue;
    _used_charging_num = used_charging_num.boolValue;
    _average_per_day_add = average_per_day_add.boolValue;
    _charging_rate = charging_rate.boolValue;
    _dabiao = dabiao.boolValue;
    [self initAll];
}

- (void)showCommistionHistoryInfoWithHistory_ok_num:(NSNumber *)history_ok_num history_store_num:(NSNumber *)history_store_num history_money:(NSNumber *)history_money today_ok_num:(NSNumber *)today_ok_num today_store_num:(NSNumber *)today_store_num today_money:(NSNumber *)today_money merge_money:(NSNumber *)merge_money{
    _history_ok_num = history_ok_num.boolValue;
    _history_store_num = history_store_num.boolValue;
    _history_money = history_money.boolValue;
    _today_ok_num = today_ok_num.boolValue;
    _today_store_num = today_store_num.boolValue;
    _today_money = today_money.boolValue;
    _merge_money = merge_money.boolValue;
    
    [self initAll];
}

#pragma mark - ChooseCalenderDateViewControllerDelegate

- (void)getStartDate:(NSString *)startDate endDate:(NSString *)endData{
    _labelStart.text = startDate;
    _labelEnd.text = endData;
    
    if (_typString.integerValue == 1) {
        [self loadListData];
    }else if (_typString.integerValue == 3){//我的提成，历史明细
        [self loadCommistionHistoryFunc];
    }else{
        [self loadData];
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
